/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package tableCellRender;

import java.awt.Component;
import javax.swing.JTable;
import javax.swing.JTextField;
import static javax.swing.SwingConstants.CENTER;
import javax.swing.table.TableCellRenderer;
import otros.Util;

/**
 *
 * @author FERRETERIA
 */
public class Vendedor implements TableCellRenderer  {
    private int filaSel;
    private boolean fuera;

    public Vendedor (int fila, boolean fuera) {
        super();
        filaSel = fila;
        this.fuera = fuera;
    }
    
    @Override
    public Component getTableCellRendererComponent(final JTable jtable, Object value, boolean selected, boolean focused, int row, int column) {
        JTextField t = new JTextField();
        t.setBorder(null);
        t.setOpaque(true);
        t.setHorizontalAlignment(CENTER);
        if ( value != null) {
            String vendedor = "";
            try {
                int valor = Integer.parseInt((String) (value));
                switch(valor) {
                    case 0:
                        vendedor = "Ale";
                        break;
                    case 1:
                        vendedor = "Onan";
                        break;
                    case 2:
                        vendedor = "Tino";
                        break;
                    case 3:
                        vendedor = "Juan";
                        break;
                    default:
                        vendedor = ""+valor;
                        break;
                }
            } catch (Exception e) {
                vendedor = ""+(Integer)value;
            }
            t.setText(vendedor);
            
        } else
            t.setText("");
        t.setBackground(Util.getBackground(row,filaSel,jtable, selected, fuera));
        t.setForeground(Util.getForeground(row,filaSel,jtable,selected, fuera));          
        return t;
    }
}
